<template>
	<view class="bigbox">
		<view class="box2">
			<view>门店属性</view>
			<picker @change="x1" :value="index1" :range="list1">
				<view class="uni-input">{{list1[index1]}}</view>
			</picker>
		</view>
		<view class="box2">
			<view>门店类型</view>
			<picker @change="x2" :value="index2" :range="list2">
				<view class="uni-input">{{list2[index2]}}</view>
			</picker>
		</view>
		<view class="box2">
			<view>所属城市</view>
			<input v-model="a3" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>所属市场</view>
			<picker @change="x3" :value="index3" :range="list3">
				<view class="uni-input">{{list3[index3]}}</view>
			</picker>
		</view>
		<view class="box2">
			<view>门店名称</view>
			<input v-model="a5" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>详细地址</view>
			<input v-model="a6" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>当前位置</view>
			<input v-model="a7" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>车位数</view>
			<input v-model="a8" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>车辆档位</view>
			<input v-model="a9" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>月卖车量</view>
			<input v-model="a10" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>月按揭量</view>
			<input v-model="a11" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>倾向竞争对手</view>
			<input v-model="a12" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>历史秒拒客户数</view>
			<input v-model="a13" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>特征</view>
			<input v-model="a14" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>需求</view>
			<input v-model="a15" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>老板姓名</view>
			<input v-model="a17" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>老板性别</view>
			<input v-model="a18" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>老板电话号码</view>
			<input v-model="a19" type="text" placeholder="请输入">
		</view>
		<view class="box2">
			<view>老板身份证号</view>
			<input v-model="a20" type="text" placeholder="请输入">
		</view>
		<view class="box_s">
			<view class="box4">
				<view class="box4_1" @click="uploading(1)">
					<image :src="a16" mode=""></image>
				</view>
				<view>上传门店照片</view>
			</view>
			<view class="box4">
				<view class="box4_1" @click="uploading(2)">
					<image :src="a21" mode=""></image>
				</view>
				<view>上传营业执照</view>
			</view>
			<view class="box4">
				<view class="box4_1" @click="uploading(3)">
					<image :src="a22" mode=""></image>
				</view>
				<view>上传附加材料</view>
			</view>
		</view>
		<view class="box2">
			<view>备注</view>
			<input v-model="a23" type="text" placeholder="请输入">
		</view>
		<view class="all_btn btn_all" @click="tj()">提交</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:'',
				list1:[],
				list2:[],
				list3:[],
				arr1:[],
				arr2:[],
				arr3:[],
				index1: 0,
				index2: 0,
				index3: 0,
				a1:'',
				a2:'',
				a3:'',
				a4:'',
				a5:'',
				a6:'',
				a7:'',
				a8:'',
				a9:'',
				a10:'',
				a11:'',
				a12:'',
				a13:'',
				a14:'',
				a15:'',
				a16:'../../static/80.png',
				a17:'',
				a18:'',
				a19:'',
				a20:'',
				a21:'../../static/80.png',
				a22:'../../static/80.png',
				a23:'',
			}
		},
		onLoad:function(option){
			this.id = option.id
			this.shujuType('mdsx')
			this.shujuType('mdlx')
			this.shujuType('sssc')
		},
		methods: {
			tj:function(){
				let a1 
				let a2
				let a3
				this.arr1.forEach((item)=>{
					if(this.list1[this.index1] == item.title){
						a1 = item.value
					}
				})
				this.arr2.forEach((item)=>{
					if(this.list2[this.index2] == item.title){
						a2 = item.value
					}
				})
				this.arr3.forEach((item)=>{
					if(this.list3[this.index3] == item.title){
						a3 = item.value
					}
				})
				this.$post('base/fxjBase_11/add',{
					query01:a1,
					query02:a2,
					query03:this.a3,
					query04:a3,
					query05:this.a5,
					query06:this.a6,
					query07:this.a7,
					query08:this.a8,
					query09:this.a9,
					query10:this.a10,
					query11:this.a11,
					query12:this.a12,
					query13:this.a13,
					query14:this.a14,
					query15:this.a15,
					query16:this.a16,
					query17:this.a17,
					query18:this.a18,
					query19:this.a19,
					query20:this.a20,
					query21:this.a21,
					query22:this.a22,
					query23:this.a23,
				}).then((res)=>{
					if(res.data.success){
						uni.showToast({
							title:'添加成功',
							icon:'none'
						})
						setTimeout(()=>{
							uni.redirectTo({
							    url: '../cwg_shxq/cwg_shxq?id=' + this.id
							});
						},1000)
					}
				})
			},
			uploading:function(index){
				uni.chooseImage({
				    success: (chooseImageRes) => {
				        const tempFilePaths = chooseImageRes.tempFilePaths;
						this.img = tempFilePaths[0]
				        uni.uploadFile({
				            url: this.$headUrl + 'sys/common/upload',
				            filePath: tempFilePaths[0],
				            name: 'file',
							header:{
								'X-Access-Token': uni.getStorageSync('token')
							},
				            success: (res) => {
								console.log(JSON.parse(res.data))
								if(JSON.parse(res.data).success){
									if(index == 1){
										this.a16 = JSON.parse(res.data).message
									}else if(index == 2){
										this.a21 = JSON.parse(res.data).message
									}else if(index == 3){
										this.a22 = JSON.parse(res.data).message
									}
								}
								
				            }
				        });
				    }
				});
			},
			x3: function(e) {
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.index3 = e.target.value
			},
			x2: function(e) {
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.index2 = e.target.value
			},
			x1: function(e) {
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.index1 = e.target.value
			},
			shujuType:function(type){
				this.$get('sys/dict/getDictItems/' + type).then((item)=>{
					console.log(item.data.result)
					if(type == 'mdsx'){//门店属性
						this.arr1 = item.data.result
						item.data.result.forEach((item)=>{
							this.list1.push(item.title)
						})
					}else if(type == 'mdlx'){//门店类型
						this.arr2 = item.data.result
						item.data.result.forEach((item)=>{
							this.list2.push(item.title)
						})
					}else if(type == 'sssc'){//所属市场
						this.arr3 = item.data.result
						item.data.result.forEach((item)=>{
							this.list3.push(item.title)
						})
					}
					
				})
			},
		}
	}
</script>

<style>
	.box_s{
		display: flex;
		justify-content: flex-start;
		align-items: center;
		flex-wrap: wrap;
	}
	.box4>view>image{
		width: 100%;
		height: 100%;
		position: absolute;
		top: 0;
		left: 0;
		z-index: -1;
	}
	.box4_1{
		width: 316rpx;
		height: 211rpx;
		font-size:22rpx;
		font-family:Microsoft YaHei;
		font-weight:400;
		color:#666666;
		margin: 30rpx 0;
		margin-bottom: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		position: relative;
		z-index: 10;
		/* margin-left: 30rpx; */
	}
	.box4{
		width: 50%;
		text-align: center;
		flex-wrap: wrap;
		margin-top: 20rpx;
		font-size: 30rpx;
		color: rgba(153,153,153,1);
	}
	.btn_all{
		margin: 30rpx 0;
	}
	.box2>input{
		text-align: right;
		font-size:30rpx;
	}
	.box2{
		height:88rpx;
		background:rgba(250,250,250,0.3);
		border:1px solid rgba(230,230,230,1);
		border-radius:10rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 20rpx;
		box-sizing: border-box;
		font-size:30rpx;
		font-family:PingFang SC;
		font-weight:500;
		color:rgba(0,0,0,1);
		margin-top: 20rpx;
	}
	.bigbox{
		padding: 0 30rpx;
		box-sizing: border-box;
	}
</style>
